package scala.com.shujia.jichu

object Demo9Apply {
  def main(args: Array[String]): Unit = {
    //    val b1: Book = new Book()
    //    b1.apply() // 当作是一个普通的方法

    val b1: Book = Book("中华上下五千年", 999)

    println(b1)
  }
}

object Book {
  def apply(name:String,price:Int): Book = {
    new Book(name,price)
  }
}

class Book(name: String, price: Int) {
  val _name: String = name
  val _price: Int = price

  override def toString: String = "书名:" + _name + ", 价格:" + _price
}